<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/commonJS.jsp" %>
<%@ include file="../common/commonLabel.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>采购单付款信息修改</title>
<script type="text/javascript">
//保存并查询
function doUpd(){
	if(check()){
		if(document.all["to.orderId"].value!=""){
			if(confirm("确认修改信息?")){
				document.all.operate.value = "updinfo";
				document.forms[0].submit();
			}
		}else{
			_alert("至少选择一个采购单进行付款");
		}
	}
}
 //限制添加快捷内容的字数  
var maxLength =30; 
function MaxInput(fo,len) {
	if(len!=""){
		maxLength=len;
	}
	if (fo.value.length > maxLength) {
		alert("输入内容过多！");
		fo.value = fo.value.substring(0, maxLength);
	}
}
function doback(){
	document.all.operate.value = "";
	document.forms[0].submit();
}
//选择统一供应商的采购单信息
function setpurc(obj,pid,sid,sname,money){
	var supplierid = document.all["to.supplierid"];
	var suppliername = document.all["to.suppliername"];
	var orderId = document.all["to.orderId"];
	if(obj.checked){
		if(supplierid.value==""){
			supplierid.value = sid;
			suppliername.value = sname;
			orderId.value = pid+",";
			document.all["to.tpmoney"].value = money;
		}else{
			if(supplierid.value == sid){
				orderId.value += pid+",";
				document.all["to.tpmoney"].value = (document.all["to.tpmoney"].value-0) + (money-0);
			}else{
				obj.checked = false;
				_alert("请选择同一家供应商进行付款。");
			}
		}
	}else{
		orderId.value = orderId.value.replace(pid+",","");
		document.all["to.tpmoney"].value = (document.all["to.tpmoney"].value-0) - (money-0);
		if(orderId.value==""){
			supplierid.value = "";
			suppliername.value = "";
		}
	}
	document.all["to.billmoney"].value = document.all["to.tpmoney"].value;
	document.all["to.realmoney"].value = document.all["to.tpmoney"].value;
}
</script>
</head>
<body>
<form action="<%=path %>/paymoney.action" method="post">
<table width="760" border="0" cellpadding="0" cellspacing="0" >
  <tr>
     <td>
     <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" class="MainBody">
      <tr>
        <td class="MainBody_title"><hello:forValue type="title" /></td>
      </tr>
        <tr>
          <td valign="top"><input name="operate" type="hidden" value=""/>
          <input name="to.tpid" type="hidden" value="${updinfo.tpid}" />
          <input name="to.orderId" type="hidden" value="${updinfo.orderId}"/>
          <input name="to.supplierid" type="hidden" value="${updinfo.supplierid}"/>
          <input name="to.suppliername" type="hidden" value="${updinfo.suppliername}"/>
          <div align="right" style="padding: 10 50 10 0;">
			<input type="button" class="btn" value="修 改" onclick="doUpd()"/>&nbsp;&nbsp;
			<input type="reset" class="btn" value="重 置" />&nbsp;&nbsp;
			<input type="button" class="btn" value="返 回" onclick="doback()"/>&nbsp;&nbsp;</div>
          <table  border="0" cellpadding="0" cellspacing="0" class="MainBody_table">
                <tr>
                  <td  colspan="6" class="bg_title">采 购 单 付 款 信 息</td>
                </tr>
                <tr>
                  <th width="13%" nowrap="nowrap">经手人</th>
                  <td width="20%" ><input name="to.createuser" value="${updinfo.createuser}" type="text" class="readinput" readonly /></td>
                  <th width="13%" nowrap="nowrap">付款日期</th> 
                  <td width="20%"><input name="to.tpdate" type="text" value="${updinfo.tpdate}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" class="Wdate"/></td>
                  <th width="13%" nowrap="nowrap">付款人</th>
                  <td width="20%"><select name="to.tpperson" style="width: 98%">
                  		<c:forEach var="person" varStatus="status" items="${personlist}">
						<option value="${person.personname }" <c:if test="${updinfo.tpperson==person.personname}">selected</c:if>>${person.personname }</option>
						</c:forEach></select></td>
                </tr>
                
                <tr>
                  <th nowrap="nowrap">应付金额</th> 
                  <td><input name="to.tpmoney" type="text" value="${updinfo.tpmoney}" class="readinput" style="width: 80%" readonly />/元</td>
                  <th nowrap="nowrap">付款方式</th>
                  <td><select name="to.tpway" style="width: 80%" ></select></td>
                  <th nowrap="nowrap">实付金额</th>
                  <td><input name="to.realmoney" type="text" value="${updinfo.realmoney}" maxlength="50" style="width: 80%" check="checkBlank,checkNaN" title="实付金额"/>/元</td>
                </tr>
                
                <tr>
                  <th nowrap="nowrap">发票金额</th>
                  <td ><input name="to.billmoney" type="text" value="${updinfo.billmoney}" maxlength="50" style="width: 80%" check="checkNaN" title="发票金额"/>/元</td>
                  <th nowrap="nowrap">发票类型</th> 
                  <td ><select name="to.billtype" style="width: 95%"></select></td>
                  <th nowrap="nowrap">发票编号</th>
                  <td ><input name="to.bill" type="text" value="${updinfo.bill}" maxlength="50"  check="checkInt" title="发票编号"/></td>
                </tr>
                
                <tr>
                  <th align="center" nowrap="nowrap" >备注信息</th> 
                  <td colspan="5"><textarea name="to.remark" style="width: 100%;" rows="5" onblur="MaxInput(this,100)">${updinfo.remark}</textarea></td>
                </tr>
            </table>
            <div style="width:760;height: 300px;overflow: auto; ">
            <table  border="0" cellpadding="0" cellspacing="0" class="MainBody_table">
				<tr>
                  <td colspan="7" class="bg_title" nowrap="nowrap">采 购 单 信 息</td></tr>
                <tr>
                  <th nowrap="nowrap"></th>
                  <th width="20%" nowrap="nowrap">采购单编号</th>
                  <th width="28%" nowrap="nowrap">供应商名称</th>
                  <th width="12%" nowrap="nowrap">联系人</th>
                  <th width="12%" nowrap="nowrap">采购员</th> 
                  <th width="15%" nowrap="nowrap">合同金额</th>
                  <th width="12%" nowrap="nowrap">采购进度</th>
                </tr>
                <c:forEach items="${purchaselist}" varStatus="status" var="rows">
                <tr>
                	<td nowrap="nowrap"><INPUT type='checkbox' onclick="setpurc(this,'${rows.purchaseid}','${rows.supplierid}','${rows.suppliername}','${rows.summoney}')" <c:if test="${rows.tpflag=='y'}">checked</c:if> name='supp'> </td>
					<td nowrap="nowrap">${rows.purchaseid}</td>
					<td nowrap="nowrap">${rows.suppliername}</td>
					<td nowrap="nowrap">${rows.linkman}</td>
					<td nowrap="nowrap">${rows.buyer}</td>
					<td nowrap="nowrap">${rows.summoney}</td>
					<td nowrap="nowrap">${rows.progress}</td>
                </tr>
                </c:forEach>
                <c:if test="${empty purchaselist}">
					<tr>
						<td colspan="7" align="center">暂时没有您可以浏览的数据</td>
					</tr>
				</c:if>
            </table>
            </div>
		</td>
	</tr>
</table></td></tr></table>
<script type="text/javascript">
doSelectInfo(document.all["to.tpway"],'tpway','${updinfo.tpway}',false);
doSelectInfo(document.all["to.billtype"],'billtype','${updinfo.billtype}',false);
</script>
</form>
</body>
</html>